<template>
    <div class="top">
        <div class="nav">
            <h5>秒杀活动 / 添加秒杀活动</h5>
            <button @click="gotos()">返回</button>
        </div>
        <div class="center">
            <h4>请填写秒杀活动相关信息</h4>
            <br>
            <div class="conter-main">
                <h4>活动标题:</h4>
                <input placeholder="请输入名称" clearable class="ipt" v-model="prom_k.k_title" />
            </div>
            <div class="conter-main conter-pict">
                <h4>活动封面:</h4>
                <div class="picture">
                    <div class="up-picture">+</div>
                    <p>上传照片</p>
                </div>
				<br>
				<p>
                <h4>只能上传jpg/png文件,并不超过500kb</h4>
				</p>
            </div>
            <br>
            <div class="conter-main" style="margin-top:30px">
                <h4>活动状态:</h4>
                <el-switch v-model="value2" class="mb-2"
                    style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949" active-text="上线状态"
                    inactive-text="下线状态" />
            </div>
			<div class="conter-main">
				<h4>活动日期:</h4>
				<div  class="data_time">
					<el-date-picker v-model="timeRange"  type="datetimerange"
				      range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
				      @change="getList" :disabledDate="disablesDate" />
				</div>
			</div>
			
            <button class="btn" @click="add()">立即添加</button>
            <button class="cancel">取消</button>
        </div>
    </div>
</template>

<script >

import {ref} from 'vue'
import { reactive } from 'vue'
import { addPromKill, promKill } from '../api/api.js'
export default {
	
    name: 'cao',
	setup() {
		const value2 = ref(true)
		//添加的字段
		const prom_k = ref({
			kill_title: '',
			value2: '',
		})
		
		return {
			value2,
			prom_k
		}
	},
   methods: {
   	gotos() {
   		this.$router.push('/Seconds')
   	},
	add() {
		let _data = this.prom_k
		let random1 = Math.random()*(5*100)+10
		
		addPromKill(_data)
			.then(res => {
				console.log(res);
				this.promKill();
				
			})
			.catch(err => {
				console.log(err);
			})
	}
   },
	disablesDate(time){
		  const _minTime = Date.now() + 24 * 60 * 60 * 1000 * 7 //最小时间可选前七天
		  const _maxTime = Date.now() - 24 * 60 * 60 * 1000 * 1 //最大时间可选今天
		  return time.getTime() <= _maxTime || time.getTime() > _minTime
	}
}
</script>
<style scoped>
	.disUoloadBtn .el-upload--picture-card{
	    display:none;   /* 上传按钮隐藏 */
	}
input[type=text]::placeholder{
	color: #a8abb2;
	}
* {
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: left;
}

.top {
    width: calc(100% - 60px);
    height: 100vh;
    padding: 35px 30px;
    background-color: #f0f0f0;
}

.nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 30px;
}

.nav>button {
    margin-left: 83.5%;
    width: 60px;
    height: 30px;
    text-align: center;
    border: none;
    background: #38a28a;
    color: #fff;
    border-radius: 5px;
    cursor: pointer;
}

.conter-main {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    height: 40px;
    margin-bottom: 30px;
    line-height: 50px;
}
.ipt::placeholder {
	color: #a8abb2;
}
.ipt {
    width: 300px;
    height: 30px;
    border: 1px solid #dcdfe6;
    border-radius: 5px;
    outline: none;
    padding-left: 10px;
    font-size: 12px;
    margin-left: 15px;
    font-weight: 700;
}

.center {
    width: calc(100% - 60px);
	height: calc(100% - 120px);
    padding: 30px 30px;
    background-color: #fff;
}

.conter-pict>p {
    width: 100%;
    padding-left: 80px;
    font-size: 12px;
}

.up-picture {
    text-align: center;
    font-size: 50px;
    color: #898989;
}

.picture {
    text-align: center;
    width: 90px;
    height: 90px;
    background-color: #fafafa;
    font-size: 14px;
    border: 1px dashed #898989;
    margin-top: -10px;
    margin-left: 15px;
}


.picture>p{
    text-align: center;
    margin-top: -15px;
}

.top>button {
    background-color: #38a28a;
    color: white;
    width: 70px;
    height: 30px;
    float: right;
    border: none;
    border-radius: 5px;
    text-align: center;
}
.catalogue>div{
    width: 70px;
    height: 30px;
    border: 1px solid #38a28a;
    border-radius: 5px;
    margin-left: 15px;
    text-align: center;
    line-height: 30px;
    font-size: 14px;
}
.catalogue>div>span:nth-child(1){
    font-size: 18px;
    margin-right: 5px;
}

.mb-2,
.data_time{
	margin-left: 15px;
}
.btn{
    background-color: #38a28a;
    color: white;
    width: 70px;
    height: 30px;
    border: none;
    border-radius: 4px;
    text-align: center;
    margin-left: 85px;
}
.cancel{
    width: 60px;
    height: 30px;
    text-align: center;
    margin-left: 15px;
    background: #fff;
    border: 1px solid #e9ecf0;
    border-radius: 4px;
}
</style>
